0.1 By Month

0.2 CCAMLR Units

0.3 Distance

0.4 Time

0.5 Velocity

0.6 Angles

1 Correlated random walk

Process Model

\[ d_{t} \sim T*d_{t-1} + Normal(0,\Sigma)\] \[ x_t = x_{t-1} + d_{t} \]

1.1 Parameters

For each individual:

\[\theta = \text{Mean turning angle}\] \[\gamma = \text{Move persistence} \]

For both behaviors process variance is: \[ \sigma_{latitude} = 0.1\] \[ \sigma_{longitude} = 0.1\]

1.2 Behavioral States

\[ \text{For each individual i}\] \[ Behavior_1 = \text{traveling}\] \[ Behavior_2 = \text{foraging}\]

\[ \alpha_{i,1,1} = \text{Probability of remaining traveling when traveling}\] \[\alpha_{i,2,1} = \text{Probability of switching from Foraging to traveling}\]

\[\begin{matrix} \alpha_{i,1,1} & 1-\alpha_{i,1,1} \\ \alpha_{i,2,1} & 1-\alpha_{i,2,1} \\ \end{matrix} \]

With the probability of switching states:

\[logit(\phi_{traveling}) = \alpha_{Behavior_{t-1}}\]

\[\phi_{foraging} = 1 - \phi_{traveling} \]

1.3 Continious tracks

The transmitter will often go dark for 10 to 12 hours, due to weather, right in the middle of an otherwise good track. The model requires regular intervals to estimate the turning angles and temporal autocorrelation. As a track hits one of these walls, call it the end of a track, and begin a new track once the weather improves. We can remove any micro-tracks that are less than three days. Specify a duration, calculate the number of tracks and the number of removed points. Iteratively.

How did the filter change the extent of tracks?

sink(“Bayesian/Multi_RW.jags”) cat(" model{

#Constants
pi <- 3.141592653589

##argos observation error##
argos_prec[1:2,1:2] <- inverse(argos_sigma*argos_cov[,])

#Constructing the covariance matrix
argos_cov[1,1] <- 1
argos_cov[1,2] <- sqrt(argos_alpha) * rho
argos_cov[2,1] <- sqrt(argos_alpha) * rho
argos_cov[2,2] <- argos_alpha

for(i in 1:ind){
for(g in 1:tracks[i]){

## Priors for first true location
#for lat long
y[i,g,1,1:2] ~ dmnorm(argos[i,g,1,1,1:2],argos_prec)

#First movement - random walk.
y[i,g,2,1:2] ~ dmnorm(y[i,g,1,1:2],iSigma)

###First Behavioral State###
state[i,g,1] ~ dcat(lambda[]) ## assign state for first obs

#Process Model for movement
for(t in 2:(steps[i,g]-1)){

#Behavioral State at time T
logit(phi[i,g,t,1]) <- alpha_mu[state[i,g,t-1]] 
phi[i,g,t,2] <- 1-phi[i,g,t,1]
state[i,g,t] ~ dcat(phi[i,g,t,])

#Turning covariate
#Transition Matrix for turning angles
T[i,g,t,1,1] <- cos(theta[state[i,g,t]])
T[i,g,t,1,2] <- (-sin(theta[state[i,g,t]]))
T[i,g,t,2,1] <- sin(theta[state[i,g,t]])
T[i,g,t,2,2] <- cos(theta[state[i,g,t]])

#Correlation in movement change
d[i,g,t,1:2] <- y[i,g,t,] + gamma[state[i,g,t]] * T[i,g,t,,] %*% (y[i,g,t,1:2] - y[i,g,t-1,1:2])

#Gaussian Displacement
y[i,g,t+1,1:2] ~ dmnorm(d[i,g,t,1:2],iSigma)
}

#Final behavior state
logit(phi[i,g,steps[i,g],1]) <- alpha_mu[state[i,g,steps[i,g]-1]] 
phi[i,g,steps[i,g],2] <- 1-phi[i,g,steps[i,g],1]
state[i,g,steps[i,g]] ~ dcat(phi[i,g,steps[i,g],])

##  Measurement equation - irregular observations
# loops over regular time intervals (t)    

for(t in 2:steps[i,g]){

# loops over observed locations within interval t
for(u in 1:idx[i,g,t]){ 
zhat[i,g,t,u,1:2] <- (1-j[i,g,t,u]) * y[i,g,t-1,1:2] + j[i,g,t,u] * y[i,g,t,1:2]

#for each lat and long
#argos error
argos[i,g,t,u,1:2] ~ dmnorm(zhat[i,g,t,u,1:2],argos_prec)
}
}
}
}
###Priors###

#Process Variance
iSigma ~ dwish(R,2)
Sigma <- inverse(iSigma)

##Mean Angle
tmp[1] ~ dbeta(10, 10)
tmp[2] ~ dbeta(10, 10)

# prior for theta in 'traveling state'
theta[1] <- (2 * tmp[1] - 1) * pi

# prior for theta in 'foraging state'    
theta[2] <- (tmp[2] * pi * 2)

##Move persistance
# prior for gamma (autocorrelation parameter)
#from jonsen 2016
gamma[1] ~ dbeta(5,2)   ## gamma for state 1: traveling
dev ~ dbeta(1,1)            ## a random deviate to ensure that gamma[1] > gamma[2]
gamma[2] <- gamma[1] * dev      ## gamma for state 1


##Behavioral States

#Hierarchical structure across motnhs
#Intercepts
alpha_mu[1] ~ dnorm(0,0.386)
alpha_mu[2] ~ dnorm(0,0.386)

#Variance
alpha_tau[1] ~ dt(0,1,1)I(0,)
alpha_tau[2] ~ dt(0,1,1)I(0,)

#Probability of behavior switching 
lambda[1] ~ dbeta(1,1)
lambda[2] <- 1 - lambda[1]

##Argos priors##
#longitudinal argos error
argos_sigma ~ dunif(0,10)

#latitidunal argos error
argos_alpha~dunif(0,10)

#correlation in argos error
rho ~ dunif(-1, 1)


}"
,fill=TRUE)

sink()

##      user    system   elapsed 
##   551.987     3.411 30258.524

1.4 Chains

##                         Type       Size    PrettySize  Rows Columns
## jagM          rjags.parallel 1735503496  [1] "1.6 Gb"     6      NA
## data                    list   66108896   [1] "63 Mb"     9      NA
## argos                  array   42969704   [1] "41 Mb"    34      21
## obs                    array   42969704   [1] "41 Mb"    34      21
## j                      array   21492400 [1] "20.5 Mb"    34      21
## mdat              data.frame   16339200 [1] "15.6 Mb" 49859      47
## d     SpatialPointsDataFrame   14373352 [1] "13.7 Mb" 49859      49
## oxy               data.frame   13572520 [1] "12.9 Mb" 49859      49
## m                      ggmap   13116096 [1] "12.5 Mb"  1280    1280
## sxy                     list   12089464 [1] "11.5 Mb"   194      NA
##             used   (Mb) gc trigger   (Mb)  max used   (Mb)
## Ncells   1785061   95.4    3886542  207.6   3886542  207.6
## Vcells 267002479 2037.1  504447222 3848.7 504404742 3848.4

1.4.1 Compare to priors

1.5 Parameter Summary

##   parameter         par          mean       lower       upper
## 1  alpha_mu alpha_mu[1]  1.0183105092  0.68114532  1.39652886
## 2  alpha_mu alpha_mu[2] -2.5784032701 -3.01021263 -2.14528667
## 3     gamma    gamma[1]  0.9374273346  0.90011479  0.97008022
## 4     gamma    gamma[2]  0.1957252640  0.15838259  0.23345299
## 5     theta    theta[1]  0.0003042014 -0.02240764  0.02176058
## 6     theta    theta[2]  6.1269746582  6.04276323  6.19280686

2 Behavioral Prediction

2.1 Spatial Prediction

2.1.1 Per Animal

2.2 Autocorrelation in behavior

2.3 Behavioral description

2.4 Location of Behavior

3 Overlap with Krill Fishery

4 Time spent in grid cell

4.1 Traveling

##                         Type      Size     PrettySize    Rows Columns
## pc                    tbl_df 322844920 [1] "307.9 Mb" 6193000      10
## data                    list  66108896    [1] "63 Mb"       9      NA
## argos                  array  42969704    [1] "41 Mb"      34      21
## obs                    array  42969704    [1] "41 Mb"      34      21
## j                      array  21492400  [1] "20.5 Mb"      34      21
## mdat              data.frame  16339200  [1] "15.6 Mb"   49859      47
## d     SpatialPointsDataFrame  14373352  [1] "13.7 Mb"   49859      49
## oxy               data.frame  13572520  [1] "12.9 Mb"   49859      49
## temp                   ggmap  13116144  [1] "12.5 Mb"    1280    1280
## mxy               data.frame  10205752   [1] "9.7 Mb"   31426      57
##            used  (Mb) gc trigger   (Mb)  max used   (Mb)
## Ncells  1629901  87.1    4547696  242.9   5684620  303.6
## Vcells 61539770 469.6  165297264 1261.2 504404742 3848.4